package abstractEntities;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import org.hibernate.annotations.GenericGenerator;

import entities.Departament;
import entities.Itens;
import entities.Map;

/**
 * AbstractMap entity provides the base persistence definition of the Map
 * entity. @author MyEclipse Persistence Tools
 */
@MappedSuperclass
public abstract class AbstractMap implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -7628490698972758146L;
	private Integer idMap;
	private Departament departament;
	private String mapName;
	private Integer lockLevel;
	private Set<Map> mapsForIdMap1 = new HashSet<Map>(0);
	private Set<Itens> itenses = new HashSet<Itens>(0);
	private Set<Map> mapsForIdMap2 = new HashSet<Map>(0);

	// Constructors

	/** default constructor */
	public AbstractMap() {
	}

	/** minimal constructor */
	public AbstractMap(Departament departament, String mapName,
			Integer lockLevel) {
		this.departament = departament;
		this.mapName = mapName;
		this.lockLevel = lockLevel;
	}

	/** full constructor */
	public AbstractMap(Departament departament, String mapName,
			Integer lockLevel, Set<Map> mapsForIdMap1, Set<Itens> itenses,
			Set<Map> mapsForIdMap2) {
		this.departament = departament;
		this.mapName = mapName;
		this.lockLevel = lockLevel;
		this.mapsForIdMap1 = mapsForIdMap1;
		this.itenses = itenses;
		this.mapsForIdMap2 = mapsForIdMap2;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "idMap", unique = true, nullable = false)
	public Integer getIdMap() {
		return this.idMap;
	}

	public void setIdMap(Integer idMap) {
		this.idMap = idMap;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idDepartament", nullable = false)
	public Departament getDepartament() {
		return this.departament;
	}

	public void setDepartament(Departament departament) {
		this.departament = departament;
	}

	@Column(name = "mapName", nullable = false)
	public String getMapName() {
		return this.mapName;
	}

	public void setMapName(String mapName) {
		this.mapName = mapName;
	}

	@Column(name = "lockLevel", nullable = false)
	public Integer getLockLevel() {
		return this.lockLevel;
	}

	public void setLockLevel(Integer lockLevel) {
		this.lockLevel = lockLevel;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "mapsForIdMap2")
	public Set<Map> getMapsForIdMap1() {
		return this.mapsForIdMap1;
	}

	public void setMapsForIdMap1(Set<Map> mapsForIdMap1) {
		this.mapsForIdMap1 = mapsForIdMap1;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "itensmap", catalog = "skillworld", joinColumns = { @JoinColumn(name = "idMap", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "idItem", nullable = false, updatable = false) })
	public Set<Itens> getItenses() {
		return this.itenses;
	}

	public void setItenses(Set<Itens> itenses) {
		this.itenses = itenses;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "mapmap", catalog = "skillworld", joinColumns = { @JoinColumn(name = "idMap1", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "idMap2", nullable = false, updatable = false) })
	public Set<Map> getMapsForIdMap2() {
		return this.mapsForIdMap2;
	}

	public void setMapsForIdMap2(Set<Map> mapsForIdMap2) {
		this.mapsForIdMap2 = mapsForIdMap2;
	}

}